package stud.aistar.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import stud.aistar.entity.RegOffice;
import stud.aistar.mapper.RegOfficeMapper;
import stud.aistar.service.IRegOfficeService;

import java.util.List;

/**
 * Created by Administrator on 2019/9/28.
 */
@Service
@Transactional
public class RegOfficeImpl implements IRegOfficeService {

    @Autowired
    private RegOfficeMapper regOfficeMapper;
//    查询所有预约信息
    @Override
    public List<RegOffice> findAll() {
        List<RegOffice> list = regOfficeMapper.findAll();
        return list;
    }
//    根据病人id查询所有病人预约信息(for李明)
    @Override
    public List<RegOffice> findByPatientId(Integer pid) {
        List<RegOffice> list = regOfficeMapper.findByPatientId(pid);
        return list;
    }

//    根据医生id查询医生下面的所有病人的预约信息(for王雨)
    @Override
    public List<RegOffice> findByDoctorId(Integer did) {
        List<RegOffice> list=regOfficeMapper.findByDoctorId(did);
        return list;
    }

//    控制医生在一个时间段放号的数量
    @Override
    public Integer findCount(Integer did, Integer tid) {
        Integer count = regOfficeMapper.findCount(did,tid);
        return  count;
    }

//    创建预约信息
    @Override
    public void saveReg(RegOffice regOffice) {
        regOfficeMapper.saveReg(regOffice);
    }

    @Override
    public void changeStatus(Integer id) {
        regOfficeMapper.changeStatus(id);
    }

    @Override
    public void forgiveStatus(Integer id) {

        regOfficeMapper.changeStatus(id);
    }


    //    根据id查询一条预约信息
    @Override
    public RegOffice findById(Integer id) {
        RegOffice regOffice = regOfficeMapper.findById(id);
        return  regOffice;
    }

//    更改预约单完成状态(for王雨)
    @Override
    public void updateStatus(Integer id) {
        regOfficeMapper.updateStatus(id);
    }

//    更改预约单信息(for李明)
    @Override
    public void updateReg(RegOffice regOffice) {

        regOfficeMapper.updateReg(regOffice);
    }

    @Override
    public RegOffice findOne(Integer pid, Integer did, Integer tid) {
        return regOfficeMapper.findOne(pid,did,tid);
    }

    @Override
    public List<RegOffice> findByUserId(Integer uid) {
        return regOfficeMapper.findByUserId(uid);
    }
}
